<template>
  <div class="find">
    <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
      <div class="header">
        <!-- 标签 -->
        <van-cell-group>
          <van-cell title="发现" class="topHeader" />
        </van-cell-group>
        <!-- 面试技巧 -->
        <div class="center">
          <newTitle title="面试技巧" path="/Home/skillpage"></newTitle>
          <div class="skills">
            <skills
              :item="item"
              v-for="(item, index) in skillsArr"
              :key="index"
            ></skills>
          </div>
        </div>
        <!-- 市场数据 -->
        <div class="market">
          <new-title title="市场数据"></new-title>
          <div class="position">
            <span>北京</span>
            <span>产品经理</span>
          </div>
          <div class="data" v-for="(item, index) in 5" :key="index">
            <span class="years">2020年</span>
            <div class="boxData">
              <div class="miData">¥12320</div>
            </div>
            <span class="iconfont" style="color:#00d47a">&#xe651;</span>
            <span class="iconfont" style="color:#fe6d67">&#xe64e;</span>
            <span class="rightNum">10%</span>
          </div>
          <div class="more">展开更多 <i class="iconfont">&#xe652;</i></div>
        </div>
        <!-- 面经分享 -->
        <div class="share">
          <newTitle title="面经分享" path="/Home/sharepage"></newTitle>
          <share
            :item="item"
            v-for="(item, index) in shareArr"
            :key="index"
          ></share>
        </div>
        <!-- 到底了 -->
        <div class="low">---------- 到底了 ----------</div>
      </div>
    </van-pull-refresh>
  </div>
</template>
<script>
import newTitle from './newTitle'
import skills from './skills'
import share from './share'
import { getSkills, getshare } from '@/api/find.js'
export default {
  name: 'find',
  components: {
    newTitle,
    skills,
    share
  },
  data () {
    return {
      skillsArr: [],
      shareArr: [],
      refreshing: false
    }
  },
  created () {
    this.GetSkills()
    this.GetShare()
  },
  methods: {
    // 下拉刷新数据
    async onRefresh () {
      this.skillsArr = []
      this.shareArr = []
      await this.GetSkills()
      await this.GetShare()
      setTimeout(() => {
        this.refreshing = false
      }, 1000)
    },
    // 获取面试技巧数据
    async GetSkills () {
      const res = await getSkills({ start: 0, limit: 3 })
      // console.log(res)
      this.skillsArr = res.data.list
    },
    // 获取面经分享数据
    async GetShare () {
      const res = await getshare()
      // console.log(res)
      this.shareArr.push(...res.data.list)
    }
  }
}
</script>
<style lang="less" scoped>
.find {
  background-color: #f7f4f5;
  padding-bottom: 60px;

  .header {
    /deep/ .van-cell {
      opacity: 1;
      font-size: 18px;
      font-weight: 600;
    }
    .van-hairline--top-bottom::after {
      border-width: 0 0 2px 0;
    }
    .topHeader {
      text-align: center;
      box-shadow: 0px 2px 4px 0px rgba(24, 26, 57, 0.04);
    }
  }
  .center {
    margin-top: 1px;
    .skills {
      padding-top: 20px;
      background-color: #fff;
    }
  }
  .market {
    margin: 10px 0 10px 0;
    padding-bottom: 21px;
    background-color: #fff;
    .position {
      padding: 21px 15px 27px;
      display: flex;
      justify-content: left;
      span {
        padding: 6px;
        margin-right: 15px;
        color: #545671;
        opacity: 1;
        background: #eceaea;
        border-radius: 4px;
        font-size: 14px;
        font-weight: 400;
      }
    }
    .data {
      padding: 0 15px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 21px;
      .years {
        opacity: 1;
        font-size: 14px;
        color: #545671;
      }
      .boxData {
        flex: 1;
        width: 218px;
        height: 14px;
        background-color: #ebdfdf;
        border-radius: 8px;
        margin: 0 10px;
        .miData {
          width: 70%;
          height: 14px;
          font-size: 11px;
          color: #fff;
          background-color: #fe6d67;
          border-radius: 8px;
          text-align: right;
          padding-right: 7px;
          line-height: 15px;
        }
      }
      .rightNum {
        font-size: 14px;
        color: #5b5d75;
      }
    }
    .more {
      font-size: 14px;
      font-weight: 600;
      color: #545671;
      text-align: center;
      i {
        font-size: 5px;
        color: #ebdfdf;
      }
    }
  }

  .low {
    opacity: 1;
    font-size: 14px;
    font-weight: 400;
    text-align: center;
    color: #b4b4bd;
    margin: 20px 0;
  }
}
</style>
